//;(function($){
	$(function(){
		var syncPageNav = $('#syncPageNav');
		syncPageNav.find("select").change(function(){
			var val=$(this).val();
			var url = syncPageNav.attr("data-remote");
			url = url+"/1/"+val;
			window.location = url;
		});
		
		
        $('#vendorSetupForm').validate({
            rules:	{
                vendor_name:	{required: true},
                address1:	{required: true},
                province_name:	{required: true},
                city_name:	{required: true},
                country_name:	{required: true},
                counties_name:	{required: true},
                contact_name:	{required: true},
                fax:	{required: true},
                contact_cell_phone:	{required: true, number: true},
                contact_email:	{required: true, email: true}
            },
            submitHandler:	function(form){
                $(form).ajaxBind({
                    data: function(){
                        var data = creatData($(form));
                        data.vendor_contacts = [];
                        for (var i = 0; i < 1; i++) {
                            data.vendor_contacts[i] =
                            {
                                supply_name:$('#supplyName_' + i).val(),
                                supply_cell_phone:$('#supplyCellPhone_' + i).val(),
                                supply_phone:$('#supplyPhone_' + i).val(),
                                supply_email:$('#supplyEmail_' + i).val()
                            }
                        }
                        return data;
                    }
                }, {
                    loading:	$(form),
                    type:		'auto',
                    successMsg:	'Add successful',
                    onSuccess:	function(data){

                    },
                    errorMeg:	'something error.'
                });
                return false;
            }
        });

        $('#brandsSettingForm').validate({
            submitHandler:	function(form){
                $(form).ajaxBind({},{
                    loading:	$(form),
                    type:		'auto',
                    onSuccess:	function(data, elem){
                        $("#msgBox").attr('class', 'msgBoxSuccess').html('Brands Setting Successfully.');
                        $("#msgBox").parent().slideDown();
                    }
                });
            }
        });

        $('#vendorSearch').ajaxBind({}, {
            loading:	true,
            onSuccess:	function(data){
                listRefresh(data, $('#vendorListTemp'), $('#vendorList'));
            }
        });
        
        $('#vendorBulkForm').validate({
            rules:	{
                vendorTemplate:	{required: true}
            },
            submitHandler:	function(form){
               form.submit();
            }
        });
        
        $('#batchSearch').validate({
            rules:	{
                batchId:	{number: true}
            },
            submitHandler:	function(form){
                $(form).ajaxBind({}, {
                    loading:	$(form),
                    onSuccess:	function(data){
                         listRefresh(data, $('#batchListTemp'), $('#batchList'));
                    }
                });
                return false;
            }
        });
	});

//})(jQuery);